<template>
  <q-layout view="lHh Lpr lFf">
    <q-header elevated>
      <q-toolbar>

        <q-toolbar-title>
          {{ 'Xray Timetables' }}
        </q-toolbar-title>

        <log-out-button />


      </q-toolbar>
    </q-header>

    <q-page-container>
      <router-view />
    </q-page-container>
  </q-layout>
</template>

<script setup>
import {authStore} from "stores/auth-store";
import {LocalStorage} from "quasar";
import {api} from "boot/axios";

const auth = authStore()

auth.$subscribe(async (mutation, state) => {
  LocalStorage.set('accessToken', state.accessToken)
  api.defaults.headers.common.Authorization = `Bearer ${state.accessToken}`
  LocalStorage.set('user', state.user)
})

import LogOutButton from "components/LogOutButton.vue";

defineOptions({
  name: 'AuthLayout'
})

</script>
